home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-16 | 18.8 KB | 582 lines | [TEXT/KAHL] |
- $$Loop ModelessDialogs
- $$Message MM Modeless Dialog, mm:mmMD_$Worksheet.name$.cp
-
- $$File mm:mmMD_$Worksheet.name$.cp
- /* mmMD_$Worksheet.name$ Handle this dialog */
- /* $CopyRight$ */
-
- /* File name: mmMD_$Worksheet.name$.c
- Function: Handle this modeless dialog.
-
- This dialog is called when:
-
- History: $Date$ Original by $Author$
-
- */
-
- #include "mmCommon$Prototype.name$.h" /* Common */
- #include "Common$Prototype.name$.h" /* Common */
-
- /* ======================================================= */
- /* ======================================================= */
-
- /* Routine: Init */
- /* Purpose: This procedures purpose is to set the window pointer to nil, */
- /* this is used to tell the other routines */
-
- void CmmMD$Worksheet.name$::Init()
- {
-
-
- inherited::Init();
-
- $$Loop Control.type = Button
- this->Enable_$Control.name$ = $Control.Active$; /* Button */
- $$EndLoop
- $$Loop Control.type = HotRect
- $$if Control.HotSpot
- this->Enable_$Control.name$ = $Control.Active$; /* HotSpot */
- $$endif
- $$EndLoop
- $$Loop Control.type = Checkbox
- this->Enable_$Control.name$ = $Control.Active$; /* Checkbox */
- $$if Control.Selected
- this->Value_$Control.name$ = 1;
- $$endif
- $$if Control.Unselected
- this->Value_$Control.name$ = 0;
- $$endif
- $$EndLoop
- $$Loop Control.type = Radio
- this->Enable_$Control.name$ = $Control.Active$; /* Radio */
- $$if Control.Selected
- this->Value_$Control.name$ = 1;
- $$endif
- $$if Control.Unselected
- this->Value_$Control.name$ = 0;
- $$endif
- $$EndLoop
- $$Loop Control.type = ScrollBar
- this->Enable_$Control.name$ = $Control.Active$; /* ScrollBar */
- this->Value_$Control.name$ = $Control.ValueScroll$;
- $$EndLoop
- $$Loop Control.type = Icon
- this->Enable_$Control.name$ = $Control.Active$; /* Icon button */
- $$EndLoop
- $$Loop Control.type = Sicn
- this->Enable_$Control.name$ = $Control.Active$; /* Sicn button */
- $$EndLoop
- $$Loop Control.type = Picture
- $$if Control.NonGraphic
- this->Enable_$Control.name$ = $Control.Active$; /* Picture button */
- $$endif
- $$EndLoop
- $$Loop Control.type = UButton
- this->Enable_$Control.name$ = $Control.Active$; /* Plugin button */
- $$EndLoop
- $$Loop Control.type = UToggle
- this->Enable_$Control.name$ = $Control.Active$; /* Plugin toggle */
- $$if Control.Selected
- this->Value_$Control.name$ = 1;
- $$endif
- $$if Control.Unselected
- this->Value_$Control.name$ = 0;
- $$endif
- $$EndLoop
- $$Loop Control.type = UGauge
- this->Enable_$Control.name$ = $Control.Active$; /* Plugin gauge */
- this->Value_$Control.name$ = $Control.ValueScroll$;
- $$EndLoop
- $$Loop Control.type = Popup
- this->Enable_$Control.name$ = $Control.Active$; /* Popup menu */
- this->Value_$Control.name$ = $Control.SelectedID$;
- $$EndLoop
- $$Loop Control.type = Palette
- this->Enable_$Control.name$ = $Control.Active$; /* Palette */
- this->Value_$Control.name$ = $Control.ValueScroll$;
- $$EndLoop
- $$Loop Control.type = List
- this->List_$Control.name$ = nil; /* List */
- SetRect(&this->ListRect_$Control.name$,$Control.LeftPosition$,$Control.TopPosition$,$Control.RightPosition$,$Control.BottomPosition$); /* left,top,right,bottom */
- $$EndLoop
- $$Loop Control.type = EditText
- this->TE_$Control.name$ = nil; /* Edit Text */
- SetRect(&this->TERect_$Control.name$,$Control.LeftPosition$,$Control.TopPosition$,$Control.RightPosition$,$Control.BottomPosition$); /* left,top,right,bottom */
- GetIndString(this->TEStr_$Control.name$,sResD_$Control.name$,1);/* ...Edit text, default value */
- $$EndLoop
- }
-
- /* ======================================================= */
-
- /* Routine: Update */
- /* Purpose: This procedures purpose is to refresh this window, update it, */
- /* when we are uncovered by another window. */
-
- void CmmMD$Worksheet.name$::Update(WindowPtr theWindow)
- {
- GrafPtr SavedPort; /* Save the current port so we can restore to it */
- Rect tempRect; /* Temporary rectangle variable */
- Rect rTempRect; /* Temporary rectangle variable */
- short DType; /* Type of dialog item */
- Handle DItem; /* Handle to the dialog item */
- ControlHandle CItem; /* Control handle */
- RGBColor Saved_ForeColor; /* Place to save colors */
- RGBColor Saved_BackColor; /* Place to save colors */
-
-
- if ((this->theWindow != nil) && (theWindow == this->theWindow))/* Only do if we are the window to update */
- {
- GetPort(&SavedPort); /* Get the current port */
- SetPort(theWindow); /* Point to our port for drawing in our window */
- if (Has.ColorQD) /* See if color QuickDraw is around */
- {
- GetForeColor(&Saved_ForeColor); /* Save the fore color */
- GetBackColor(&Saved_BackColor); /* Save the back color */
-
- RGBForeColor(&Black_ForeColor); /* Set the fore color to Black */
- RGBBackColor(&White_BackColor); /* Set the back color to White */
- } /* End of IF */
-
- $$Loop Control.type = Button
- $$if Control.Default
- /* This is the default selection, when RETURN is pressed. */
- HiliteDefaultButton(theWindow,ResD_$Control.name$);
-
- $$endif Control.Default
- $$EndLoop Control.type
- $$Loop Control.type = Line
- /* Draw a line, $Control.FullName$ */
- $$if Control.GrayLine
- PenPat(qd.gray); /* Set the gray pen pattern */
- $$endif Control.GrayLine
- $$if Control.LineWidth ! 1
- PenSize($Control.LineWidth$,$Control.LineWidth$);
- $$endif Control.LineWidth
- MoveTo($Control.LeftPosition$,$Control.TopPosition$); /* Horz,vert, Move to starting position */
- LineTo($Control.RightPosition$,$Control.BottomPosition$); /* Horz,vert, Draw to the ending position */
- $$if Control.LineWidth ! 1
- PenSize(1,1);
- $$endif Control.LineWidth
- $$if Control.GrayLine
- PenPat(qd.black); /* Back to default pen pattern */
- $$endif Control.GrayLine
-
- $$EndLoop
- $$Loop Control.type = StaticText
- $$if Control.SpecialText
- /* Draw static text, $Control.FullName$ */
- $$if Control.TextColor ! Black
- if (Has.ColorQD) /* See if color QuickDraw is around */
- {
- DrawingColor.red = 0x$Control.RedTextColor$;
- DrawingColor.green = 0x$Control.GreenTextColor$;
- DrawingColor.blue = 0x$Control.BlueTextColor$;
- RGBForeColor(&DrawingColor); /* Set the fore color */
- RGBBackColor(&Saved_BackColor); /* Set the back color */
- }
- $$endif Control.TextColor
- $$if Control.MultipleLine
- SetRect(&tempRect,$Control.LeftPosition$,$Control.TopPosition$,$Control.RightPosition$,$Control.BottomPosition$);
- DrawStaticTextBox(sResD_$Control.name$,&tempRect,$Control.TextAlignment$,$Control.TextSize$,$Control.TextFont$,$Control.TextStyle$);
- $$endif Control.MultipleLine
- $$if Control.SingleLine
- DrawStaticLine(sResD_$Control.name$,$Control.LeftPosition$,$Control.TopPosition$,$Control.TextSize$,$Control.TextFont$,$Control.TextStyle$);
- $$endif Control.SingleLine
- $$if Control.TextColor ! Black
- if (Has.ColorQD) /* See if color QuickDraw is around */
- {
- RGBForeColor(&Black_ForeColor); /* Set the fore color */
- RGBBackColor(&White_BackColor); /* Set the back color */
- }
- $$endif Control.TextColor
-
- $$endif Control.SpecialText
- $$EndLoop
- $$Loop Control.type = List
- UpdateTheList(theWindow->visRgn,this->List_$Control.name$,&this->ListRect_$Control.name$,
- $Control.TextSize$,$Control.TextFont$,$Control.TextStyle$,true);
-
- $$EndLoop
- TextSize(12);
- TextFont(systemFont); /* Select the Font that we want */
- TextFace(0); /* Select the style that we want */
-
- if (Has.ColorQD) /* See if color QuickDraw is around */
- {
- RGBForeColor(&Saved_ForeColor); /* Restore the fore color */
- RGBBackColor(&Saved_BackColor); /* Restore the back color */
- }
-
- this->UpdateExtras(); /* HOOK, allow user update code */
-
- DrawDialog(theWindow); /* Draw the rest of the controls */
- SetPort(SavedPort); /* Restore the port that we saved at the start */
- }
- }
-
- /* ======================================================= */
-
- /* Routine: Open */
- /* Purpose: This procedures purpose is to open this window and set all */
- /* of the initial conditions, such as default edit text. */
-
- void CmmMD$Worksheet.name$::Open()
- {
- Rect tempRect; /* Temporary rectangle variable */
- short DType; /* Type of dialog item */
- Handle DItem; /* Handle to the dialog item */
- ControlHandle CItem; /* Control handle */
- long LTemp,LTemp2,theLong; /* Get selection, temp holding */
- DialogPtr theDialog;
-
-
- if (this->theWindow == NIL)
- {
- this->theWindow = GetNewDialog(ResD_$Worksheet.name$,NIL,(WindowPtr)-1 );/* Bring in the dialog resource */
- theDialog = this->theWindow;
- SetPort(theDialog); /* Prepare to add conditional text */
-
- $$if Worksheet.Center
- tempRect = theDialog->portRect; /* Get the windows position and size */
- $$if Worksheet.CenterHorz
- tempRect.left = ((screenRect.bounds.right - screenRect.bounds.left) - (tempRect.right - tempRect.left)) / 2; /* Center Horz */
- $$endif Worksheet.CenterHorz
- $$if Worksheet.CenterVert
- tempRect.top = ((screenRect.bounds.bottom - screenRect.bounds.top) - (tempRect.bottom - tempRect.top)) / 3; /* 1/3 vert */
- if (tempRect.top < 40) /* Keep below the menu bar */
- tempRect.top = 40;
- $$endif Worksheet.CenterVert
- MoveWindow(theDialog,tempRect.left,tempRect.top,true);
-
- $$endif
- $$if ModelessDialog.Movable
- Doing_MovableModal = true;
-
- $$endif ModelessDialog.Movable
- $$Loop Control.type = Button
- /* Button */
- SetupNormalControl(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,0);
-
- $$EndLoop Control.type
- $$Loop Control.type = Checkbox
- /* Checkbox */
- SetupNormalControl(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,this->Value_$Control.name$);
-
- $$EndLoop Checkbox
- $$Loop Control.type = Radio
- /* Radio button */
- SetupNormalControl(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,this->Value_$Control.name$);
-
- $$EndLoop Radio
- $$Loop Control.type = List
- /* Make a List */
- Make_A_List(&this->List_$Control.name$,&this->ListRect_$Control.name$,
- theDialog,sResD_$Control.name$,$Control.TextSize$,$Control.TextFont$,$Control.TextStyle$,true);
-
- $$EndLoop
- $$Loop Control.type = HotRect
- /* Draw a Hotspot or Rectangle */
- SetupHotSpot(theDialog,ResD_$Control.name$,$Control.MakeHotSpot$,$Control.LineWidth$,
- $Control.ShadowWidth$,sResD_$Control.name$,this->Enable_$Control.name$);
-
- $$EndLoop
- $$Loop Control.type = EditText
- GetDItem(theDialog,ResD_$Control.name$,&DType,&DItem,&tempRect);/* Get the item handle */
- GetIndString(sTemp,sResD_$Control.name$,1); /* ...Edit text, default value */
- SetIText(DItem,sTemp); /* Set the default text string */
- SelIText(theDialog,ResD_$Control.name$,0,300);
-
- $$EndLoop
- $$Loop Control.type = Popup
- SetupPopupMenu(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,
- mResD_$Control.name$,this->Value_$Control.name$);
-
- $$EndLoop
- $$Loop Control.type = Picture
- $$if Control.NonGraphic
- /* Draw a picture */
- LTemp = ResD_N_$Control.name$; /* Picture ID and resize flag */
- $$if Control.ClipPicture
- LTemp = 0x00010000 | LTemp;
- $$endif Control.ClipPicture
- SetupTheItem(theDialog,ResD_$Control.name$,true,true,
- this->Enable_$Control.name$,false,&tempRect,LTemp,0);
-
- $$endif Control.NonGraphic
- $$EndLoop
- $$Loop Control.type = Palette
- /* Draw a Palette */
- SetupPalette(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,
- $Control.NumRows$,$Control.NumColumns$,ResD_N_$Control.name$,$Control.HMethod$);
-
- $$EndLoop
- $$Loop Control.type = Icon
- $$if Control.NonGraphic
- /* Draw an Icon button */
- SetupIconSicn(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,
- ResD_N_$Control.name$,ResD_H_$Control.name$);
-
- $$endif Control.NonGraphic
- $$EndLoop
- $$Loop Control.type = Sicn
- /* Draw a Sicn */
- $$if Control.Graphic
- SetupIconSicn(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,
- ResD_N_$Control.name$,ResD_N_$Control.name$);
- $$endif Control.Graphic
- $$if Control.NonGraphic
- SetupIconSicn(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,
- ResD_N_$Control.name$,ResD_H_$Control.name$);
- $$endif Control.NonGraphic
-
- $$EndLoop
- $$Loop Control.type = UButton
- SetupPlugin(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,
- ResD_N_$Control.name$,ResD_H_$Control.name$,sResD_$Control.name$);
-
- $$EndLoop
- $$Loop Control.type = UToggle
- SetupPlugin(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,
- ResD_N_$Control.name$,ResD_H_$Control.name$,sResD_$Control.name$);
-
- $$EndLoop
- $$Loop Control.type = UGauge
- SetupPlugin(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,
- ResD_N_$Control.name$,ResD_H_$Control.name$,sResD_$Control.name$);
- SetupMinMaxValue(theDialog,ResD_$Control.name$,$Control.MinScroll$,$Control.MaxScroll$,this->Value_$Control.name$);
-
- $$EndLoop
- $$Loop Control.type = ScrollBar
- SetupTheItem(theDialog,ResD_$Control.name$,true,true,this->Enable_$Control.name$,true,&tempRect,0,0);
- SetupMinMaxValue(theDialog,ResD_$Control.name$,$Control.MinScroll$,$Control.MaxScroll$,this->Value_$Control.name$);
-
- $$EndLoop
-
- $$Link Worksheet.Open
-
- this->OpenExtras(); /* Call the user Open procedure */
-
- ShowWindow(theDialog); /* Open a dialog box */
- SelectWindow(theDialog); /* Lets see it */
- }
- else
- SelectWindow(this->theWindow); /* Lets see it */
- }
-
- /* ======================================================= */
-
- /* Routine: Close_$Worksheet.name$ */
- /* Purpose: This procedures purpose is to close this window and clear */
- /* the window pointer variable */
-
- void CmmMD$Worksheet.name$::Close(WindowPtr theWindow)
- {
- Rect tempRect; /* Temporary rectangle */
- short DType; /* Type of dialog item */
- Handle DItem; /* Handle to the dialog item */
-
-
- if ((this->theWindow != NIL) && (theWindow == this->theWindow))/* Only close if it is us and we were open */
- {
- $$Link Worksheet.Close
-
- $$if ModelessDialog.Movable
- Doing_MovableModal = false;
-
- $$endif ModelessDialog.Movable
- DisposDialog(theWindow); /* Close on the screen and Flush the dialog out of memory */
- this->theWindow = nil; /* Make sure our other routines know that we are closed */
- }
- }
-
- /* ======================================================= */
-
- /* Routine: HandleEvent */
- /* Purpose: This procedures purpose is to handle all actions, such as buttons being pressed. */
- /* This is the real meat of this unit and is where the code is for acting upon the users actions. */
-
- void CmmMD$Worksheet.name$::HandleEvent(EventRecord *theEvent,WindowPtr theWindow,short itemHit)
- {
- short Index; /* For looping */
- Point myPt; /* For the local mouse position */
- short DType; /* Type of dialog item */
- Handle DItem; /* Handle to the dialog item */
- Rect tempRect; /* Temporary rectangle */
- ControlHandle CItem; /* Control handle */
- short temp; /* temp integer */
- short code; /* temp integer */
- short theSelection; /* For Palettes */
- Boolean DoubleClick; /* For sensing double clicks in a list */
- DialogPtr theDialog;
-
-
- this->ExitDialog = false; /* Do not close the dialog yet */
- $$if HasLists
- if ((theEvent->what == mouseDown) && (this->theWindow != nil))
- {
- SetPort(this->theWindow); /* Set the port to our dialog */
- myPt = theEvent->where; /* Get the position where the mouse was pressed */
- GlobalToLocal(&myPt); /* Change from global to local location */
-
- $$Loop Control.type = List
- if (PtInRect(myPt,&this->ListRect_$Control.name$))
- ClickInTheList(myPt,theEvent->modifiers,this->List_$Control.name$,$Control.TextSize$,$Control.TextFont$,$Control.TextStyle$,true);
-
- $$EndLoop Control.type
- }
- $$endif HasLists
-
- if ((this->theWindow != nil) && (this->theWindow == theWindow))
- {
- theDialog = this->theWindow;
-
- CheckKeysInDialog(theDialog,&DoubleClick,theEvent,&itemHit);
-
- myPt = theEvent->where; /* Get the position where the mouse was pressed */
- GlobalToLocal(&myPt); /* Change from global to local location */
-
- this->FilterTheHit(&itemHit,theEvent); /* Give the user the itemhit */
-
- if (itemHit > 0) /* Skip if user set to zero */
- {
- GetDItem(theDialog,itemHit,&DType,&DItem,&tempRect);/* Get which item was pressed */
- CItem = (ControlHandle)DItem; /* Change the pointer for getting to the control */
- }
-
- /* Handle it real time */
- $$Loop Control.type = Button
- if (itemHit == ResD_$Control.name$) /* Handle the Button being pressed */
- {
- $$Link Control.Select
- $$if Control.ExitDialog
- this->ExitDialog = true; /* Close this dialog, exit */
- $$endif Control.ExitDialog
- }
-
- $$EndLoop Control.type
- $$Loop Control.type = Checkbox
- if (itemHit == ResD_$Control.name$) /* Handle the checkbox being pressed */
- {
- temp = GetCtlValue(CItem); /* Get the current Checkbox value */
- SetCtlValue(CItem, (temp + 1) & 1); /* Toggle the value to the opposite */
- this->Value_$Control.name$ = GetCtlValue(CItem); /* Get the current Checkbox value */
- $$if Control.HasLinks
- if (this->Value_$Control.name$ == 0)
- {
- $$Link Control.Deselect
- }
- else
- {
- $$Link Control.Select
- }
- $$endif
- }
-
- $$EndLoop Control.type
- $$Loop Control.type = UButton
- $$if Control.HasLinks
- if (itemHit == ResD_$Control.name$) /* Handle the Button being pressed */
- {
- $$Link Control.Select
- }
-
- $$endif
- $$EndLoop Control.type
- $$Loop Control.type = UToggle
- if (itemHit == ResD_$Control.name$) /* Handle the checkbox being pressed */
- {
- temp = GetCtlValue(CItem); /* Get the current Checkbox value */
- SetCtlValue(CItem, (temp + 1) & 1); /* Toggle the value to the opposite */
- this->Value_$Control.name$ = GetCtlValue(CItem); /* Get the current Checkbox value */
- $$if Control.HasLinks
- if (this->Value_$Control.name$ == 0)
- {
- $$Link Control.Deselect
- }
- else
- {
- $$Link Control.Select
- }
- $$endif
- }
-
- $$EndLoop Control.type
- $$Loop Control.type = Radio
- if (itemHit == ResD_$Control.name$) /* Handle the Radio being pressed */
- {
- SetCtlValue(CItem,1);
- this->Value_$Control.name$ = 1; /* Set the current Radio value */
-
- $$Loop RadioGroup
- ClearTheRadio(theDialog,ResD_$Control.name$,&this->Value_$Control.name$);
- $$EndLoop RadioGroup
- $$Link Control.Select
- }
-
- $$EndLoop Control.type
- $$Loop Control.type = HotRect
- $$if Control.HotSpot
- $$if Control.HasLinks
- if (itemHit == ResD_$Control.name$) /* Handle the HotSpot being pressed */
- {
- $$Link Control.Select
- }
-
- $$endif
- $$endif Control.HotSpot
- $$EndLoop
- $$Loop Control.type = Popup
- /* Popup */
-
- $$EndLoop
- $$Loop Control.type = Picture
- $$if Control.NonGraphic
- $$if Control.HasLinks
- if (itemHit == ResD_$Control.name$) /* Handle the Picture being pressed */
- {
- $$Link Control.Select
- }
-
- $$endif
- $$endif Control.NonGraphic
- $$EndLoop
- $$Loop Control.type = Palette
- /* Palette */
-
- $$EndLoop
- $$Loop Control.type = Icon
- $$if Control.NonGraphic
- $$if Control.HasLinks
- if (itemHit == ResD_$Control.name$) /* Handle the Icon being pressed */
- {
- $$Link Control.Select
- }
-
- $$endif
- $$endif Control.NonGraphic
- $$EndLoop
- $$Loop Control.type = Sicn
- $$if Control.NonGraphic
- $$if Control.HasLinks
- if (itemHit == ResD_$Control.name$) /* Handle the Sicn being pressed */
- {
- $$Link Control.Select
- }
-
- $$endif
- $$endif Control.NonGraphic
- $$EndLoop
-
- }
-
- if (this->ExitDialog) /* Do the close of the dialog */
- this->Close(this->theWindow);
- }
-
- /* ======================================================= */
- /* ======================================================= */
- $$CloseFile
- $$EndLoop
-
-
-